//
//  YeeCarSectionView.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/3/8.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeCarSectionView.h"

@implementation YeeCarSectionView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame])
    {
        [self addOwnsView];
        [self bindViewModel];
    }
    return self;
}
-(void)addOwnsView
{
    
    _selectedButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [_selectedButton setImage:[[UIImage imageNamed:@"icon_zhifenda_xuanzhong"] imageWithTintColor:kNavBarThemeColor] forState:UIControlStateNormal];
    [self addSubview:_selectedButton];
    [_selectedButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).with.offset(5.0f);
        make.height.width.mas_equalTo(17);
    }];
    _shopLable=[[UILabel alloc] init];
    _shopLable.font=[UIFont Y_systemFontOfSize:14];
    _shopLable.textColor=kBlackColor;
    _shopLable.text=@"店铺店铺店铺";
    [self addSubview:_shopLable];
    [_shopLable mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.centerY.equalTo(self);
         make.height.mas_equalTo(25);
         make.left.equalTo(_selectedButton.mas_right).offset(7);
    }];
 
    _markIamgeView=[[UIImageView alloc] init];
    _markIamgeView.contentMode=UIViewContentModeScaleAspectFill;
    _markIamgeView.clipsToBounds=YES;
    [_markIamgeView setImage:[[UIImage imageNamed:@"rightBAck"] imageWithTintColor:kBlackColor]];
    [self addSubview:_markIamgeView];
    [_markIamgeView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.centerY.equalTo(self);
        make.height.width.mas_equalTo(12);
        make.left.equalTo(_shopLable.mas_right).offset(10);
    }];
    
    _couponButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [_couponButton setTitle:@"领劵" forState:UIControlStateNormal];
    _couponButton .titleLabel.font=[UIFont Y_systemFontOfSize:14];
    [_couponButton setTitleColor:kBlackColor forState:UIControlStateNormal];
    [self addSubview:_couponButton];
    [_couponButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.width.mas_equalTo(40);
        make.right.equalTo(self).with.offset(-5.0f);
    }];
    
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickheaderEvent)];
    [self addGestureRecognizer:tap];
}
-(void)clickheaderEvent
{

//    @weakify(self);
//    self.clickSignal=[RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber)
//        { @strongify(self);
//            [subscriber sendNext:@(self.section)];
//            [subscriber sendCompleted];
//        return nil;
//    } ] ;
    
    [_clickSubject sendNext:@(self.section)];
//    
}
-(void)bindViewModel
{
//    //访问数据-->好像很卡
//    _requestCommand=[[RACCommand alloc] initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input)
//                     {
//        
//    }];
    //
    _clickSubject=[RACSubject  subject];
    
    
    [self setNeedsLayout];
    
}
@end
